package com.kwok.rbac.application.service.impl;

import com.kwok.rbac.application.entity.Role;
import com.kwok.rbac.application.mapper.RoleMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kwok.rbac.application.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 角色表 服务实现类
 * </p>
 *
 * @author baomidou
 * @since 2024-05-25
 */
@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService {

    @Autowired
    private RoleMapper roleMapper;

    //根据用户id给用户分配角色
    @Override
    public Boolean addRoleToUser(Integer userId, List<Integer> roleIdList) {
        return roleMapper.addRoleToUser(userId, roleIdList) > 0;
    }

    //根据用户id查询用户担任的角色列表
    @Override
    public List<Role> getRoleListByUserId(Integer userId) {
        return roleMapper.getRoleListByUserId(userId);
    }

}
